package com.tx.collections.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


/**
 * @author ：tx
 * @version:
 */
public class HashMapDemo {
    public static void main(String[] args) {
        HashMap<String, Object> map = new HashMap<>();
        for (int i = 0; i < 16; i++) {
            map.put(String.valueOf(i),i);
        }

        System.out.println(map.get("1"));


        map.remove("1");

//        迭代器测试
//        testInterator();
    }

    private static void testInterator() {
        Map map1 = new HashMap();
        for (int i = 0; i < 16; i++) {
            map1.put(String.valueOf(i),i);
        }

        Iterator iter = map1.entrySet().iterator();        //获取key和value的set
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();        //把hashmap转成Iterator再迭代到entry
            Object key = entry.getKey();        //从entry获取key
            Object val = entry.getValue();    //从entry获取value
            System.out.println(key + "--" + val);
        }
    }
}
